package com.qs.home.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * 通用文字识别
 *
 * @Author ltzz
 * @Date 2019/8/15
 */
public class TextResultEntity implements Parcelable {
    private Long log_id;
    private Integer direction;
    private Integer words_result_num;//内容数量
    private List<Word> words_result;//识别内容
    private String filePath;//图片地址

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public Long getLog_id() {
        return log_id;
    }

    public void setLog_id(Long log_id) {
        this.log_id = log_id;
    }

    public Integer getDirection() {
        return direction;
    }

    public void setDirection(Integer direction) {
        this.direction = direction;
    }

    public Integer getWords_result_num() {
        return words_result_num;
    }

    public void setWords_result_num(Integer words_result_num) {
        this.words_result_num = words_result_num;
    }

    public List<Word> getWords_result() {
        return words_result;
    }

    public void setWords_result(List<Word> words_result) {
        this.words_result = words_result;
    }

    public TextResultEntity() {
    }

    protected TextResultEntity(Parcel in) {
        if (in.readByte() == 0) {
            log_id = null;
        } else {
            log_id = in.readLong();
        }
        if (in.readByte() == 0) {
            direction = null;
        } else {
            direction = in.readInt();
        }
        if (in.readByte() == 0) {
            words_result_num = null;
        } else {
            words_result_num = in.readInt();
        }
        words_result = in.createTypedArrayList(Word.CREATOR);
        filePath = in.readString();
    }

    public static final Creator<TextResultEntity> CREATOR = new Creator<TextResultEntity>() {
        @Override
        public TextResultEntity createFromParcel(Parcel in) {
            return new TextResultEntity(in);
        }

        @Override
        public TextResultEntity[] newArray(int size) {
            return new TextResultEntity[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        if (log_id == null) {
            parcel.writeByte((byte) 0);
        } else {
            parcel.writeByte((byte) 1);
            parcel.writeLong(log_id);
        }
        if (direction == null) {
            parcel.writeByte((byte) 0);
        } else {
            parcel.writeByte((byte) 1);
            parcel.writeInt(direction);
        }
        if (words_result_num == null) {
            parcel.writeByte((byte) 0);
        } else {
            parcel.writeByte((byte) 1);
            parcel.writeInt(words_result_num);
        }
        parcel.writeTypedList(words_result);
        parcel.writeString(filePath);
    }


    public static class Word implements Parcelable {
        private String words;

        public String getWords() {
            return words;
        }

        public void setWords(String words) {
            this.words = words;
        }

        protected Word(Parcel in) {
            words = in.readString();
        }

        public Word() {
        }

        public static final Creator<Word> CREATOR = new Creator<Word>() {
            @Override
            public Word createFromParcel(Parcel in) {
                return new Word(in);
            }

            @Override
            public Word[] newArray(int size) {
                return new Word[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeString(words);
        }
    }
}
